<template>
  <div class="">
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片 -->
    <el-card class="box-card">
      <el-table :data="rightsList" style="width: 100%" border stripe>
        <el-table-column type="index" label="#" width="180" align="center">
        </el-table-column>
        <el-table-column
          prop="authName"
          label="权限名称"
          width="180"
          align="center"
        >
        </el-table-column>
        <el-table-column prop="path" label="路径" align="center">
        </el-table-column>
        <el-table-column label="权限等级" align="center">
          <template v-slot:default="slotProps">
            <el-tag type="info" v-if="slotProps.row.level === '0'"
              >一级权限</el-tag
            >
            <el-tag type="success" v-else-if="slotProps.row.level === '1'"
              >二级权限</el-tag
            >
            <el-tag type="warning" v-else-if="slotProps.row.level === '2'"
              >三级权限</el-tag
            >
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import { GETRightList } from '../../request/api.js'
export default {
  name: 'Rights',
  data() {
    return {
      rightsList: []
    }
  },
  created() {
    this.GETRightsList()
  },
  methods: {
    async GETRightsList() {
      try {
        const { data: res } = await GETRightList('/list')
        if (!res.meta.status === 200) return this.$message.error(res.meta.msg)
        this.rightsList = res.data
        // console.log(this.rightsList)
      } catch (error) {
        this.$message.error(error)
      }
    }
  }
}
</script>

<style lang="less" scoped></style>
